﻿@using System.Globalization
@using Bonobo.Git.Server.Extensions
@model Bonobo.Git.Server.Models.GlobalSettingsModel
@{
    ViewBag.Title = Resources.Settings_Index_Title;
}

<h1>@Resources.Settings_Index_Title</h1>

@if (TempData["UpdateSuccess"] != null && (bool)TempData["UpdateSuccess"])
{
    <div class="summary-success">
        <p>@Resources.Settings_Index_UpdateSuccess</p>
    </div>
}

@using (Html.BeginForm("Index", "Settings", FormMethod.Post, new { @class = "pure-form pure-form-aligned" }))
{
    @Html.ValidationSummary(false, Resources.Settings_Index_Failed)
    
    <fieldset>

        <div class="pure-control-group">
            @Html.LabelFor(m => m.RepositoryPath)
            @Html.TextBoxFor(m => m.RepositoryPath, new { @class = "medium", autofocus = "" })<em>*</em>
            <i class="fa fa-info-circle" title="@Resources.Settings_Global_DirectoryHint"></i>
        </div>
        <div class="pure-control-group">
            @Html.LabelFor(m => m.SiteTitle)
            @Html.TextBoxFor(m => m.SiteTitle, new { @class = "medium", autofocus = "" })
            <i class="fa fa-info-circle" title="@Resources.Settings_Global_SiteTitle_Hint"></i>
        </div>
        <div class="pure-control-group">
            @Html.LabelFor(m => m.SiteLogoUrl)
            @Html.TextBoxFor(m => m.SiteLogoUrl, new { @class = "medium", autofocus = "" })
            <i class="fa fa-info-circle" title="@Resources.Settings_Global_SiteLogoUrl_Hint"></i>
        </div>
        <div class="pure-control-group">
            @Html.LabelFor(m => m.SiteFooterMessage)
            @Html.TextBoxFor(m => m.SiteFooterMessage, new { @class = "medium", autofocus = "" })
            <i class="fa fa-info-circle" title="@Resources.Settings_Global_SiteFooterMessage_Hint"></i>
        </div>
        <div class="pure-control-group">
            @Html.LabelFor(m => m.DefaultLanguage)
            @Html.DropDownListFor(m => m.DefaultLanguage, CultureInfo.GetCultures(CultureTypes.SpecificCultures).Select(cultureInfo => new SelectListItem() { Text = cultureInfo.DisplayName, Value = cultureInfo.Name, Selected = Model.DefaultLanguage == cultureInfo.Name }).OrderBy(i => i.Text))
            <i class="fa fa-info-circle" title="@Resources.Settings_Global_DefaultLanguage_Hint"></i>
        </div>
        <div class="pure-controls">
            <label for="AllowAnonymousRegistration" class="pure-checkbox">@Html.CheckBoxFor(m => m.AllowAnonymousRegistration) @Model.GetType().GetDisplayValue("AllowAnonymousRegistration") <i class="fa fa-info-circle" title="@Resources.Settings_Global_AllowAnonymousRegistration_Hint"></i></label>  
            <label for="AllowUserRepositoryCreation" class="pure-checkbox">@Html.CheckBoxFor(m => m.AllowUserRepositoryCreation) @Model.GetType().GetDisplayValue("AllowUserRepositoryCreation") <i class="fa fa-info-circle" title="@Resources.Settings_Global_AllowUserRepositoryCreation_Hint"></i></label>            
            <label for="AllowAnonymousPush" class="pure-checkbox">@Html.CheckBoxFor(m => m.AllowAnonymousPush) @Model.GetType().GetDisplayValue("AllowAnonymousPush")</label>
            <label for="IsCommitAuthorAvatarVisible" class="pure-checkbox">@Html.CheckBoxFor(m => m.IsCommitAuthorAvatarVisible) @Model.GetType().GetDisplayValue("IsCommitAuthorAvatarVisible")</label>
        </div>
        <div class="pure-controls">
            <button type="submit" class="pure-button pure-button-primary"><i class="fa fa-save"></i> @Resources.Settings_Index_Save</button>
        </div>
    </fieldset>
}
